<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	Jan 23, 2009
 ^
 + Project: 		WRecruit
 * File Name:	views/employer/tmpl/myjobs.php
 ^
 * Description: template view for my jobs
 ^
 * History:		NONE
 ^
 */

defined('_JEXEC') or die('Restricted access');

global $mainframe;
$document =& JFactory::getDocument();

//$document->addScript( 'components/com_wrecruit/js/jquery-1.7.2.min.js' );
//$document->addScript( 'components/com_wrecruit/js/jquery-ui.min.js' );
//$document->addScript( 'components/com_wrecruit/js/jquery.uniform.js' );
//$document->addScript( 'components/com_wrecruit/js/scripts.js' );
$document->addScript( 'components/com_wrecruit/js/emppopup.js' );
$document->addScript ('components/com_wrecruit/js/other_employers.js');

$document->addStyleSheet('components/com_wrecruit/css/emppopup.css');
$model = $this->getModel('wrecruit', 'WRecruitModel');



$document->addStyleSheet('components/com_wrecruit/css/'.$this->config['theme']);
$document->addStyleSheet('components/com_wrecruit/css/other_employers.css');
 

?>

<script language=Javascript>
	function confirmRemoveCandidate(){
	    return confirm("<?php echo JText::_('JS_ARE_YOU_SURE_REMOVE_CANDIDATE'); ?>");
	}
	function confirmRemoveCandidates(){
	    return confirm("<?php echo JText::_('JS_ARE_YOU_SURE_REMOVE_CANDIDATES'); ?>");
	}
	function getFieldtoSort(val) {
		window.location="index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=candidatepool&page=<?php echo JRequest::getVar('page');?>&Itemid=<?php echo JRequest::getVar('Itemid');?>&sorted_field="+val;
	}

	function removefromPools(chk){
		var checkbox = document.getElementById('frm_emp').elements[chk];
		var items ="";
		for(var i=0;i<checkbox.length;i++) {
			if(checkbox[i].checked==true){
				items = items + checkbox[i].value+",";
			}
		}
		if(items=="" || items==null){
			alert("Pls check at least one item to delete!");
		}else {
			var answer = confirm("Are you sure to delete?")
			if (answer){
				window.location = "index.php?option=com_wrecruit&c=wrecruit&task=removeMultiCandidate&Itemid=<?php echo $this->Itemid; ?>&candidates="+items;
			}
			else{
				//alert("Cancelled!")
			}
		}	
	}
</script>

<?php if ($this->config['offline'] == '1'){ ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
	<tr>
		<td valign="top" class="<?php echo $this->theme['title']; ?>"><?php echo $this->config['title']; ?>
		</td>
	</tr>
	<tr>
		<td height="25"></td>
	</tr>
	<tr>
		<td class="wrecruitmsg"><?php echo $this->config['offline_text']; ?>
		</td>
	</tr>
</table>
<?php }
else{
	if (isset($this->userrole->rolefor)){
		if ($this->userrole->rolefor == 1) // employer
		$allowed = true;
		else
		$allowed = false;
	}
	else { if ($this->config['visitorview_emp_conrolpanel'] == 1) $allowed = true; else $allowed = false; } // user not logined
	if ($allowed == true) {
		?>
		
<div class="employer-pages">
	<div class="head-line">For one of our international partners active in the chemical industry, we are looking one of our international part...</div>
	<div class="employer-panel">
		<?php include 'left_panel.php';?>
	</div>
	<div class="employer-right">
		<form name="frmPool" id="frm_emp" method="post"	action="index.php">
			<div id="candidate_pool">
				<div class="pool_title head-title">
					<h2>
					<?php echo JText::_('TITLE_CANDIDATE_POOL'); ?>
					</h2>
				</div>
				<div class="pool_header">
					<div class="sort_field">
						<span> <strong>Sort by:</strong> <!-- <span>Sort fields</span>-->
							<select id="salaryrangefrom" class="dropdown-box" name="sorted_field" onchange="getFieldtoSort(this.value)">
								<option selected="selected" value="0">Sort fields</option>
								<option value="name">name</option>
								<option value="highest_education">education</option>
								<option value="startsalary">salary range</option>

						</select> <a class="move_up-down" href="#"><img alt="Move Up/Down"
								src="components/com_wrecruit/images/arrow_up-down.png" /> </a> </span>
						<div class="multi_remove">
							<span style="cursor:pointer;" onclick="removefromPools('candidates[]')"><img alt="Multiple remove" src="components/com_wrecruit/images/remove_multiple.png"> </span>
						</div>
					</div>
					<div class="current_pool">
						<span>
							<strong>You have currently <?php echo count($this->candidatepools); ?>
									candidates in your pool</strong> 
						</span> 
						<span style="cursor:pointer;font-weight:bold;" class="arrow_down" onclick="showClearAll()"> 
							<img src="components/com_wrecruit/images/arrow_down.png" /> 
						</span><br />
						<a href="#" id="clear_all">Clear all job application</a>
					</div>
				</div>
				<div class="pool_content">
					<table>
						<tr style="background: #ccc;">
							<td style="width: 20px;"></td>
							<td style="width: 20px;"><input type="checkbox" name="all"
								id="all" onclick="checkedAll()" /></td>
							<td colspan="2"><strong>Candidates</strong></td>
						</tr>
						<?php
						if ($this->candidatepools){
							$total = count($this->candidatepools);
							$i=1;
							foreach ($this->candidatepools as $candidate){?>
						<tr>
							<td style="vertical-align: top; padding-top: 10px;"><?php echo $i;$i=$i+1;?>
							</td>
							<td style="vertical-align: top; padding-top: 10px;"><input
								type="checkbox" name="candidates[]"
								value="<?php echo $candidate->poolid;?>" />
							</td>
							<td style="position: relative;">
								<ul class="tooltip_ul">
									<li class="tooltip_li"><a href="<?php JURI::base();?>/index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=cvdetails&Itemid=<?php echo $this->Itemid; ?>&cuid=<?php echo $candidate->candidateuid;?>"><?php echo $candidate->name;?></a>
										<div class="pool_tooltip" id="candidate<?php echo $i;?>">
											<img alt=""
												src="components/com_wrecruit/images/candidate_pic.png" />
											<ul>
												<li><a class="name_on_tooltip" href="#"><?php echo $candidate->name;?>
												</a></li>
												<li><?php echo $candidate->industry;?></li>
												<li>$<?php echo $candidate->startsalary;?>&nbsp;-&nbsp;$<?php echo $candidate->endsalary;?>
												</li>
											</ul>
											<div>
												<a href="<?php JURI::base();?>/index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=cvdetails&Itemid=<?php echo $this->Itemid; ?>&cuid=<?php echo $candidate->candidateuid;?>">
													<img title="details" alt="View details"	src="components/com_wrecruit/images/view_candidate_info.png" />
												</a> <a
													href="index.php?option=com_wrecruit&c=wrecruit&task=removecandidate&poolid=<?php echo $candidate->poolid; ?>"
													onclick="return confirmRemoveCandidate();"> <img
													title="Remove" alt="remove"
													src="components/com_wrecruit/images/remove_candidate_pool.png" />
												</a>
											</div>
										</div>
									</li>
									<li><?php echo $candidate->highest_education;?></li>
								</ul>
							</td>
							<td style="text-align: right;">
								<ul>
									<li>
										<span style="cursor:pointer;font-weight:bold;" class="sendmsg" id="sendmessage" >
											<input type="hidden" name="cname<?php echo $i;?>" value="<?php echo $candidate->name;?>" />
											<input type="hidden" name="email<?php echo $i;?>" value="<?php echo $candidate->email;?>" /> 
											<input type="hidden" name="cid<?php echo $i;?>" value="<?php echo $candidate->candidateid;?>" />
											<input type="hidden" name="empid<?php echo $i;?>" value="<?php echo $candidate->employerid;?>" />
											<img src="components/com_wrecruit/images/send_message.png"	alt="send message" title="Send Message" /> 
										</span>
										 <a href="index.php?option=com_wrecruit&c=wrecruit&task=removecandidate&poolid=<?php echo $candidate->poolid; ?>"
										onclick="return confirmRemoveCandidate();"> 
										<img src="components/com_wrecruit/images/remove_candidate_pool.png"
											title="Remove" alt="remove" /> 
										</a>
									</li>
									<li>
										<span style="cursor:pointer;" class="sendmsg" id="request_cv">
											<input type="hidden" name="cname<?php echo $i;?>" value="<?php echo $candidate->candidateid;?>" />
											<input type="hidden" name="email<?php echo $i;?>" value="<?php echo $candidate->candidateuid;?>" />
											<span>Request CV detail</span>
										</span>
									</li>
								</ul>
							</td>
						</tr>
						<?php
							}
						}?>
					</table>
				</div>
				<div class="pagination">
					<?php 
					$sql = "SELECT * FROM ".$db->nameQuote('#__Vcandidatepool')." WHERE employeruid = ".$uid;
					$page = JRequest::getVar("page");
					$number_show = 5;
					if($page > 1){
						$p	=	$page;
					}
					else{
						$p	=	1;
					}
					$start	=	($p-1)*$number_show;
					$total  = $model->getTotalRows($sql);
					if($p!=1){?>
			    	<a href="index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=candidatepool&sorted_field=<?php echo JRequest::getVar('sorted_field');?>&Itemid=<?php echo JRequest::getVar('Itemid');?>&page=<?php echo $p-1;?>">Previous</a>
			    	<?php }
						for($i=0;$i<$total;$i=$i+$number_show){
							$count++;?>
					   		 <a href="index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=candidatepool&sorted_field=<?php echo JRequest::getVar('sorted_field');?>&Itemid=<?php echo JRequest::getVar('Itemid');?>&page=<?php echo ($i/$number_show)+1;?>"><? echo ($i/$number_show)+1;?></a><?php 
						}
						if($p!=$count){?>
					   		<a href="index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=candidatepool&sorted_field=<?php echo JRequest::getVar('sorted_field');?>&Itemid=<?php echo JRequest::getVar('Itemid');?>&page=<?php echo $p+1;?>">Next</a>
					<?php
						}
					?>					
				</div>

			</div>
		</form>
	</div>
	<div style="clear:both;">
	</div>
</div>
<?php } else{ // not allowed job posting echo
	//Update by Vireak on 28/06/2012
	//Add frame to this warning and some styling
	//---------------------
	echo '<div class="box-list"><div class="head-title"><h2>Oop!</h2></div>';
	echo '<span class="wr_info"><p>'.JText::_('JS_YOU_ARE_NOT_ALLOWED_TO_VIEW').'</p>';
	echo '<p>This page is reserved for the authorized employers or recruiters only. </p></span>';
	echo '</div>';
	//---------------------
}
}?>

<div id="popupContainer" class="hidden" style="text-align:left;">
     fdfddfd
</div>
<div id="overlayEffect">
</div>

<div width="100%">
<?php
if($this->config['fr_cr_txsh']) {
	echo
	'<table width="100%" style="table-layout:fixed;">
		<tr><td height="15"></td></tr>
		<tr><td style="vertical-align:top;" align="center">'.$this->config['fr_cr_txa'].$this->config['fr_cr_txb'].'</td></tr>
	</table>';
}
?>
</div>